

//游戏中用到的图片
export class GImage {

    image: HTMLImageElement;
    loaded: () => Promise<any>;
    constructor(src: string) {
        this.image = window.document.createElement("img");
        this.loaded = async () => {
            return new Promise((resolve, reject) => {
                this.image.onload = () => {
                    resolve(null);
                }
            })
        }
        //图片路径
        console.log(src, 'src');
        this.image.src = src;
    }


    //绘图(这里不应该涉及具体的绘图逻辑)
    draw(canvas: HTMLCanvasElement): void {
        let ctx = canvas.getContext('2d');
        ctx.drawImage(this.image, 0, 0, 192, 188);
    }
}